package com.minivision.sdktestdemo.model;

import java.io.File;

/**
 * Created by devtang on 2016/4/11.
 */
public class DirPathProvider extends GroupProvider {

    private static DirPathProvider sDirPathProvider;

    private DirPathProvider(MusicProvider provider) {
        super(provider);
    }

    public static DirPathProvider getInstance(MusicProvider provider) {
        if (sDirPathProvider == null) {
            synchronized (DirPathProvider.class) {
                if (sDirPathProvider == null) {
                    sDirPathProvider = new DirPathProvider(provider);
                }
            }
        }
        return sDirPathProvider;
    }

    public static void release() {
        sDirPathProvider = null;
    }

    @Override
    public String getKey(MusicProvider provider, int position) {
        String dirName = provider.get(position).getmPath();
        dirName = dirName.substring(0, dirName.lastIndexOf(File.separator));
        return dirName;
    }
}
